/* GUI CONVERTED from rerp11a.p (converter v1.75) Wed Sep 27 23:08:08 2000 */
/* rerp11a.p - Repetitive - Subcontract Shipper Print                        */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*V8:ConvertMode=Report                                                      */
/*V8:RunMode=Character,Windows                                               */
/* REVISION: 9.1      LAST MODIFIED: 10/25/99   BY: *N002* B. Gates          */
/* REVISION: 9.1      LAST MODIFIED: 11/17/99   BY: *N04H* Vivek Gogte       */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane  */
/* REVISION: 9.1      LAST MODIFIED: 07/29/00   BY: *N0GV* Mudit Mehta       */
/* REVISION: 9.1      LAST MODIFIED: 08/18/00   BY: *N0MC* Annasaheb Rahane  */
/* REVISION: 9.1      LAST MODIFIED: 08/23/00   BY: *N0N9* B. Gates          */
/* REVISION: 9.1      LAST MODIFIED: 09/14/00   BY: *L13V* Vandna Rohira     */

/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */
/*         THIS PROGRAM IS A BOLT-ON TO STANDARD PRODUCT MFG/PRO.           */
/* ANY CHANGES TO THIS PROGRAM MUST BE PLACED ON A SEPARATE ECO THAN        */
/* STANDARD PRODUCT CHANGES.  FAILURE TO DO THIS CAUSES THE BOLT-ON CODE TO */
/* BE COMBINED WITH STANDARD PRODUCT AND RESULTS IN PATCH DELIVERY FAILURES.*/
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

          {mfdeclre.i}
          {gplabel.i} /* EXTERNAL LABEL INCLUDE */

 /* ********** Begin Translatable Strings Definitions ********** */

  &SCOPED-DEFINE rerp11a_p_1 "Mode of Transport:"
 /* Maxlen:23 Comment: */

 &SCOPED-DEFINE rerp11a_p_2 "Carrier Shipment Ref:"
 /* Maxlen:23 Comment: abbreviation for Carrier Shipment Reference*/

 &SCOPED-DEFINE rerp11a_p_3 "Vehicle ID:"
 /* Maxlen:23 Comment: */

 &SCOPED-DEFINE rerp11a_p_4 "Operation"
 /* Maxlen:10 Comment: */

 &SCOPED-DEFINE rerp11a_p_5 "Qty Shipped"
 /* Maxlen:20 Comment: abbreviation for Quantity Shipped*/

 &SCOPED-DEFINE rerp11a_p_6 "Tare Weight"
 /* Maxlen:20 Comment: */

 &SCOPED-DEFINE rerp11a_p_13 "Item Number!Description"
 /* Maxlen:24 Comment: */

 &SCOPED-DEFINE rerp11a_p_14 "WO ID!PO Number"
 /* Maxlen:10  Comment:abbreviation for Work Order ID!Purchase Order Number */

 &SCOPED-DEFINE rerp11a_p_15 "Op!Line"
 /* Maxlen:8 Comment: abbreviation for Operation!Line*/

 &SCOPED-DEFINE rerp11a_p_16 "Op Description"
 /* Maxlen:23 Comment: abbreviation for Operation Description*/

 &SCOPED-DEFINE rerp11a_p_20 "Qty"
 /* Maxlen:20 Comment: abbreivation for quantity */

 &SCOPED-DEFINE rerp11a_p_21 "Net!Weight"
 /* Maxlen:20 Comment: */

 &SCOPED-DEFINE rerp11a_p_22 "Tare!Weight"
 /* Maxlen:20 Comment: */

 &SCOPED-DEFINE rerp11a_p_23 "Gross!Weight"
 /* Maxlen:20 Comment: */

 &SCOPED-DEFINE rerp11a_p_25 "Company"
 /* Maxlen:8 Comment: */


/*N0GV*------------START COMMENT----------------
 * &SCOPED-DEFINE rerp11a_p_7 "Ship Date:"
 * /* Maxlen:20 Comment: */
 *
 * &SCOPED-DEFINE rerp11a_p_8 "Print Date:"
 * /* Maxlen:20 Comment: */
 *
 * &SCOPED-DEFINE rerp11a_p_9 "Page:"
 * /* Maxlen:20 Comment: */
 *
 * &SCOPED-DEFINE rerp11a_p_10 "Ship To:"
 * /* Maxlen:20 Comment: */
 *
 * &SCOPED-DEFINE rerp11a_p_11 "Ship Via:"
 * /* Maxlen:11 Comment: */
 *
 * &SCOPED-DEFINE rerp11a_p_12 "FOB Point:"
 * /* Maxlen:11 Comment: */
 *
 * &SCOPED-DEFINE rerp11a_p_17 "Lots Shipped:"
 * /* Maxlen:18 Comment: */
 *
 * &SCOPED-DEFINE rerp11a_p_18 "Lot:"
 * /* Maxlen:10 Comment: */
 *
 * &SCOPED-DEFINE rerp11a_p_19 "Ref:"
 * /* Maxlen:10 Comment: abbreviation for reference*/
 *
 * &SCOPED-DEFINE rerp11a_p_24 " Shipment Weight Summary "
 * /* Maxlen:70 Comment: frame title*/
 *
 * &SCOPED-DEFINE rerp11a_p_26  "          S H I P P E R"
 * /* Maxlen:23 Comment: */
 *
 * &SCOPED-DEFINE rerp11a_p_27 "      Shipper ID:"
 * /* Maxlen:17 Comment: */
 *
 * &SCOPED-DEFINE rerp11a_p_28 "P A C K I N G   L I S T"
 * /* Maxlen:23 Comment: */
 *
 * &SCOPED-DEFINE rerp11a_p_29 "    Container ID:"
 * /* Maxlen:17 Comment: */
 *
 * &SCOPED-DEFINE rerp11a_p_30 "Carrier:"
 * /* Maxlen:17 Comment: */
 *N0GV*----------END COMMENT----------------- */

 /* ********** End Translatable Strings Definitions ********** */

          /* SUBCONTRACT SHIPPER PRINT SUBPROGRAM */

          define input parameter abs_recid as recid no-undo.

          define variable company as character format "x(38)" extent 6 no-undo.
          define new shared variable addr as character format "x(38)" extent 6.
          define variable shipto as character format "x(38)" extent 6 no-undo.
          define variable shipto_id as character no-undo.
          define variable ship like so_ship no-undo.
          define variable print_date as date no-undo.
          define variable abs_shipvia like so_shipvia no-undo.
          define variable abs_fob like so_fob no-undo.
          define variable abs_trans_mode as character format "x(20)"
             label {&rerp11a_p_1} no-undo.
          define variable abs_carr_ref as character format "x(20)"
             label {&rerp11a_p_2} no-undo.
          define variable abs_veh_ref as character format "x(20)"
             label {&rerp11a_p_3} no-undo.
          define variable rpt_type as character format "x(23)" no-undo.
          define variable type_nbr as character format "x(17)" no-undo.
          define variable shipper_id as character no-undo.
          define variable ship_date as date no-undo.
          define variable i as integer no-undo.
          define variable op like wr_op column-label {&rerp11a_p_4} no-undo.
          define variable part like pt_part no-undo.
          define variable display_qty like abs_qty format "->>>>>>9.9<<<<<<"
             column-label {&rerp11a_p_5} no-undo.
          define variable par_shipfrom as character no-undo.
          define variable par_id as character no-undo.
          define variable abs_twt like abs_gwt label {&rerp11a_p_6} no-undo.
          define buffer abs_mstr2 for abs_mstr.
          define variable netweight like abs_nwt no-undo.
          define variable tareweight like abs_twt no-undo.
          define variable grossweight like abs_gwt no-undo.
          define variable descrip like pt_desc1 no-undo.
          define variable net_wt_um like pt_net_wt_um no-undo.
          define variable v_carrier like absc_carrier no-undo.

          define workfile wf_abs_wiplot
             field prodby_id like wr_lot
             field prodby_op like wr_op
             field lotserial like tr_serial
             field ref like  tr_ref
             field qty like abs_qty.

          define new shared workfile work_abs_mstr like abs_mstr.


          for first abs_mstr where recid(abs_mstr) = abs_recid no-lock: end.
          for first soc_ctrl no-lock: end.

          abs_recid = recid(abs_mstr).
          shipper_id = substring(abs_id,2).
          ship_date = abs_shp_date.


             /* GET COMPANY ADDRESS */

             update company = "".

             find ad_mstr where ad_addr = soc_comp no-lock no-error.
             if available ad_mstr then do:
/*N0N9          find ls_mstr where ls_addr = ad_addr and */
/*N0N9                             ls_type = {&rerp11a_p_25} no-lock no-error.*/
/*N0N9*/        find ls_mstr where ls_addr = ad_addr and
/*N0N9*/                           ls_type = "company" no-lock no-error.
                if not available ls_mstr and soc_comp <> "" then do:
                 {mfmsg.i 28 3} /*Not a valid company*/
                 undo , retry.
                end.

                if available ls_mstr then do:
                 addr[1] = ad_name.
                 addr[2] = ad_line1.
                 addr[3] = ad_line2.
                 addr[4] = ad_line3.
                 addr[6] = ad_country.
                 {mfcsz.i addr[5] ad_city ad_state ad_zip}.
                 {gprun.i ""gpaddr.p"" }
                 company[1] = addr[1].
                 company[2] = addr[2].
                 company[3] = addr[3].
                 company[4] = addr[4].
                 company[5] = addr[5].
                 company[6] = addr[6].
                end.
             end.


             /* GET SOLDTO & SHIPTO ADDRESSES */

             update shipto = "".

             find ad_mstr where ad_addr = abs_shipto no-lock.
             shipto_id = ad_addr.

             addr[1] = ad_name.
             addr[2] = ad_line1.
             addr[3] = ad_line2.
             addr[4] = ad_line3.
             addr[6] = ad_country.
             {mfcsz.i addr[5] ad_city ad_state ad_zip}.
             {gprun.i ""gpaddr.p"" }
             shipto[1] = addr[1].
             shipto[2] = addr[2].
             shipto[3] = addr[3].
             shipto[4] = addr[4].
             shipto[5] = addr[5].
             shipto[6] = addr[6].
             ship = ad_addr.


             for each work_abs_mstr
             exclusive-lock:
                delete work_abs_mstr.
             end.


             /* EXPLODE SHIPPER/CONTAINER TO GET LOWLEVEL ITEM DETAIL */

             {gprun.i ""rcrp11a.p"" "(input recid(abs_mstr))"}

             print_date = today.

             assign
             abs_shipvia = substr(abs__qad01,1,20)
             abs_fob = substr(abs__qad01,21,20)
             abs_carr_ref = substr(abs__qad01,41,20)
             abs_trans_mode = substr(abs__qad01,61,20)
             abs_veh_ref = substr(abs__qad01,81,20).

             for first absc_det where absc_abs_id eq abs_id:
                v_carrier = absc_carrier.
             end.

             /* PRINT HEADING */

             if abs_id begins "s" then do:
/*N0GV*         rpt_type = {&rerp11a_p_26}.
 *N0GV*         type_nbr = {&rerp11a_p_27}. */
/*N0GV*/        assign
                rpt_type = getTermLabelRt("BANNER_SHIPPER",23)
                type_nbr = getTermLabelRtColon("SHIPPER_ID",17).
             end.
             else do:
/*N0GV*         rpt_type = {&rerp11a_p_28}.
 *N0GV*         type_nbr = {&rerp11a_p_29}. */
/*N0GV*/        assign
                rpt_type = getTermLabel("BANNER_PACKING_LIST",23)
                type_nbr = getTermLabelRtColon("CONTAINER_ID",17).
             end.

             FORM /*GUI*/  header
             skip (3)
             company[1]                                   at 4
             rpt_type                                     to 79
             company[2]                                   at 4
             company[3]                                   at 4
             type_nbr                                     to 70
             shipper_id
             company[4]                                   at 4
/*N0GV*      {&rerp11a_p_7}                               to 70 */
/*N0GV*/     getTermLabelRtColon("SHIP_DATE",20)          to 70 format "x(20)"
             ship_date
             company[5]                                   at 4
/*N0GV*      {&rerp11a_p_8}                               to 70 */
/*N0GV*/     getTermLabelRtColon("PRINT_DATE",20)         to 70 format "x(20)"
             print_date
/*N0GV*      {&rerp11a_p_9}                               to 70 */
/*N0GV*/     getTermLabelRtColon("PAGE_OF_REPORT",20)     to 70 format "x(20)"
             string(page-number)
             company[6]                                   at 4
             skip (1)
/*N0GV*      {&rerp11a_p_10}                              at 46 */
/*N0GV*      ship*/
/*N0GV*/     getTermLabel("SHIP_TO",15) + ": " +
/*N0GV*/     ship                                         at 46 format "x(25)"
             skip (1)
             shipto[1]                                    at 46
             shipto[2]                                    at 46
             shipto[3]                                    at 46
             shipto[4]                                    at 46
             shipto[5]                                    at 46
             shipto[6]                                    at 46
             skip (2)
             skip(3)

/*N0GV*      {&rerp11a_p_11}                              to 12 */
/*N0GV*/     getTermLabelRtColon("SHIP_VIA",12)           to 12 format "x(12)"
             abs_shipvia

/*N0GV*      {&rerp11a_p_1}                               to 58 */
/*N0GV*/     getTermLabelRtColon("MODE_OF_TRANSPORT",24)  to 58 format "x(24)"
             abs_trans_mode

/*N0GV*      {&rerp11a_p_30}                              to 12 */
/*N0GV*/     getTermLabelRtColon("CARRIER",12)            to 12 format "x(12)"
             v_carrier

/*N0GV*      {&rerp11a_p_2}                               to 58 */
/*N0MC* /*N0GV*/ getTermLabelRtColon("CARRIER_SHIPMENT_REF",30) to 58 format "x(30)" */
/*N0MC*/     getTermLabelRtColon("CARRIER_SHIPMENT_REFERENCE",30) to 58 format "x(30)"
             abs_carr_ref

/*N0GV*      {&rerp11a_p_12}                              to 12 */
/*N0GV*/     getTermLabelRtColon("FOB_POINT",12)          to 12 format "x(12)"
             abs_fob

/*N0GV*      {&rerp11a_p_3}                               to 58 */
/*N0GV*/     getTermLabelRtColon("VEHICLE_ID",20)   to 58 format "x(20)"
             abs_veh_ref

             skip(3)
             with STREAM-IO /*GUI*/  frame heading page-top width 90 no-box no-attr-space
             no-labels.

             view frame heading.



             /* PRINT COMMENTS IF ANY */

             if abs_cmtindx > 0 then do:
                {gpcmtprt.i &type=SH &id=abs_cmtindx &pos=1}
                put skip(1).
             end.



             /* PRINT DETAIL */

             for each work_abs_mstr no-lock
             where abs_order <> "" and abs_line <> ""
             break by abs_order by abs_line by abs_item
             with frame f width 80 no-box:
                /* SET EXTERNAL LABELS */
                setFrameLabels(frame f:handle).
                accumulate abs_qty(sub-total by abs_item).
                accumulate abs_ship_qty(sub-total by abs_item).

                if first-of(abs_item) then do:
                   for each wf_abs_wiplot exclusive-lock:
                      delete wf_abs_wiplot.
                   end.
                end.

                for each abs_mstr2 no-lock
                where abs_mstr2.abs_shipfrom = work_abs_mstr.abs_shipfrom
                and abs_mstr2.abs_par_id = work_abs_mstr.abs_id:
                   create wf_abs_wiplot.
                   assign
                   prodby_id = abs_order
                   prodby_op = integer(abs_line)
                   lotserial = abs_lotser
                   ref = abs_ref
                   qty = abs_qty.
                end.

                if last-of(abs_item) then do:
                   find pt_mstr where pt_part = abs_item no-lock no-error.
                   find wr_route where wr_lot = abs_order
                   and wr_op = integer(abs_line) no-lock.

/*N04H** BEGIN DELETE SECTION
 *                 do trans:
 *                    {rewrsget.i &lot=wr_lot &op=wr_op}
 *                 end.
 *N04H** END DELETE SECTION */

                   op = integer(abs_line).

                   find wo_mstr where wo_lot = wr_lot no-lock.
                   part = abs_item.
                   if abs_item = "" then part = wo_part.
                   find pt_mstr where pt_part = part no-lock.

                   display
                   part      column-label  {&rerp11a_p_13} format "x(24)"
                   abs_order column-label  {&rerp11a_p_14}
                   op        column-label  {&rerp11a_p_15}
                   wr_desc   format "x(23)" label {&rerp11a_p_16}
                   accum sub-total by abs_item abs_qty @ display_qty
/*L13V**           pt_um. */
/*L13V*/           abs__qad02 @ pt_um WITH STREAM-IO /*GUI*/ .

                   down 1.
                   display pt_desc1 @ part WITH STREAM-IO /*GUI*/ .

                   if wr_po_nbr <> '' or wr_po_line <> 0 then do:
                      display
                      wr_po_nbr @ abs_order
                      wr_po_line @ op WITH STREAM-IO /*GUI*/ .
                   end.

                   down 1.


                   /*PRINT LINE COMMENTS*/

                   if page-size - line-count <= 5 then page.
                   {gpcmtprt.i &type=SH &id=abs_cmtindx &pos=1}



                   /*PRINT WIPLOT DETAIL*/

                   if page-size - line-count <= 5 then page.

                   for first wf_abs_wiplot no-lock:
/*N0GV*               display {&rerp11a_p_17} @ part with frame f. */
/*N0GV*/              display getTermLabel("LOTS_SHIPPED",23) + ":" @ part
/*N0GV*/              with frame f STREAM-IO /*GUI*/ .
                      down 1 with frame f.
                   end.

                   for each wf_abs_wiplot no-lock
                   break by wf_abs_wiplot.lotserial by wf_abs_wiplot.ref:
                      accumulate wf_abs_wiplot.qty
                      (sub-total by wf_abs_wiplot.ref).

                      if last-of(wf_abs_wiplot.ref) then do:
                         if page-size - line-count <= 5 then page.

                         display
/*N0GV*                  ' ' + {&rerp11a_p_18} + ' ' + */
/*N0GV*/                 ' ' + getTermLabelRtColon("LOT",4) + ' ' +
                         wf_abs_wiplot.lotserial @ part
                         accum sub-total by wf_abs_wiplot.ref
                            wf_abs_wiplot.qty
                            @ display_qty
                         pt_um
                         with frame f STREAM-IO /*GUI*/ .

                         down 1 with frame f.

                         if wf_abs_wiplot.ref > '' then do:
/*N0GV*                     display ' ' + {&rerp11a_p_19} + ' ' */
/*N0GV*/                    display ' ' + getTermLabelRtColon("REFERENCE",4)
/*N0GV*/                            + ' '
                                    + wf_abs_wiplot.ref
                            @ part
                            with frame f STREAM-IO /*GUI*/ .

                            down 1 with frame f.
                         end.
                      end.
                   end.
                end.

                
/*GUI*/ {mfguichk.i  &warn=false} /*Replace mfrpchk*/

             end.



             /*PRINT CARRIER INFORMATION*/

             {gprun.i ""rcrpcar.p"" "(abs_id, 1)"}



             /*PRINT TRAILER COMMENTS*/

             if page-size - line-count <= 5 then page.
             put skip(3).
             if page-size - line-count <= 5 then page.
             {gpcmtprt.i &type=SH &id=abs_trl_cmtindx &pos=1}
             if page-size - line-count <= 5 then page.
             put skip(3).



             /* PRINT WEIGHT SUMMARY */

             par_shipfrom = abs_shipfrom.
             par_id = abs_id.

             for each work_abs_mstr no-lock
             where abs_order <> "" and abs_line <> ""
/*N0GV       break by abs_order by abs_line by abs_item: */
/*N0GV*/     break by abs_order by abs_line by abs_item with frame f-a:
/*N0GV*/        /* SET EXTERNAL LABELS */
/*N0GV*/        setFrameLabels(frame f-a:handle).

                assign
                netweight = 0
                grossweight = 0
                tareweight = 0
                descrip = ""
                net_wt_um = ""
                part = ""
                .

                if abs_item = "" then do:
                   for first wo_mstr
                   where wo_lot = abs_order
                   no-lock:
                      part = wo_part.
                   end.

                   for first wr_route
                   where wr_lot = abs_order
                   and wr_op = integer(abs_line)
                   and wr_wipmtl_part <> ""
                   no-lock:
                      part = wr_wipmtl_part.
                   end.
                end.
                else do:
                   part = abs_item.
                end.

                for first pt_mstr where pt_part = part no-lock:
                   assign
                   netweight = pt_net_wt * abs_qty
                   grossweight = pt_ship_wt * abs_qty
                   tareweight = grossweight - netweight
                   descrip = pt_desc1
                   net_wt_um = pt_net_wt_um
                   .
                end.

                accumulate abs_qty (total by abs_item).
                accumulate netweight(total by abs_item).
                accumulate grossweight(total by abs_item).
                accumulate tareweight(total by abs_item).

                if last-of(abs_item) then do:
                   display
                   descrip
                   (accum total by abs_item abs_qty) @ abs_qty
                      column-label {&rerp11a_p_20}
                      format "->>>>>>9.9"
                   (accum total by abs_item netweight) @ netweight
                      column-label {&rerp11a_p_21}
                      format "->>>>>>9.9"
                   (accum total by abs_item tareweight) @ tareweight
                      column-label {&rerp11a_p_22}
                      format "->>>>>>9.9"
                   (accum total by abs_item grossweight) @ grossweight
                      column-label {&rerp11a_p_23}
                      format "->>>>>>9.9"
                   net_wt_um
                   with width 80 title
                   (getFrameTitle("SHIPMENT_WEIGHT_SUMMARY",33)) STREAM-IO /*GUI*/ .
                end.

                if last(abs_item) then do:
                 down 1.
                 underline netweight tareweight grossweight.
                 down 1.

                 display
                 (accum total netweight) @ netweight
                    column-label {&rerp11a_p_21} format "->>>>>>9.9"
                 (accum total tareweight) @ tareweight
                    column-label {&rerp11a_p_22} format "->>>>>>9.9"
                 (accum total grossweight) @ grossweight
                    column-label {&rerp11a_p_23} format "->>>>>>9.9"
                 net_wt_um
                 with width 80 title
                 (getFrameTitle("SHIPMENT_WEIGHT_SUMMARY",33)) STREAM-IO /*GUI*/ .
                end.

                
/*GUI*/ {mfguichk.i  &warn=false} /*Replace mfrpchk*/

             end.

             hide frame heading.
             page.
